<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>js8.3练习2参考答案</title>
	</head>
	<body>
		<!--更改一个a标签的文本、href和target-->
		
		<a href="http://www.baidu.com" target="_self">百度</a>
		<button type="button" onclick="changeToGoogle()">不喜欢百度怎么破</button>
		<script type="text/javascript">
			function changeToGoogle(){
				var link1 = document.getElementsByTagName('a')[0];
				
				// 方式1
				// link1.href = 'http://google.com';
				// link1.target = "_blank";
				
				
				// 方式2
				link1.setAttribute('href', 'http://google.com');
				link1.setAttribute('target', '_blank');
				
				
				link1.innerText = '谷歌';
			}
		</script>
	</body>
</html>
